/**
 * 
 */

/**
 * @author antonio081014
 * @since Dec 28, 2011, 8:24:07 AM
 */
import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.awt.geom.*;

public class Cut {
	public int getMaximum(int[] eelLengths, int maxCuts) {
		int N = eelLengths.length;
		int ret = 0;
		int[][] dp = new int[N + 1][maxCuts + 1];
		Arrays.sort(eelLengths);
		for (int i = 1; i <= N; i++) {
			int cuts = (int) ((eelLengths[i - 1] - 1) / 10);
			for (int j = 0; j <= maxCuts; j++) {
				for (int k = 0; k <= Math.min(j, cuts); k++) {
					int tmp = 0;
					if (k == 0)
						tmp = eelLengths[i - 1] == 10 ? 1 : 0;
					else if (k == cuts)
						tmp = (int) Math.floor(eelLengths[i - 1] / 10);
					else
						tmp = k;
					dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - k] + tmp);
					ret = Math.max(ret, dp[i][j]);
				}
			}
		}
		return ret;
	}
	 public static void main(String[] args)
	{
		long time;
		int answer;
		boolean errors = false;
		int desiredAnswer;
		
		
		time = System.currentTimeMillis();
		answer = new Cut().getMaximum(new int[]{13, 20, 13}, 2);
		System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
		desiredAnswer = 3;
		System.out.println("Your answer:");
		System.out.println("\t" + answer);
		System.out.println("Desired answer:");
		System.out.println("\t" + desiredAnswer);
		if (answer != desiredAnswer)
		{
			errors = true;
			System.out.println("DOESN'T MATCH!!!!");
		}
		else
			System.out.println("Match :-)");
		System.out.println();
		time = System.currentTimeMillis();
		answer = new Cut().getMaximum(new int[]{5, 5, 5, 5}, 2);
		System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
		desiredAnswer = 0;
		System.out.println("Your answer:");
		System.out.println("\t" + answer);
		System.out.println("Desired answer:");
		System.out.println("\t" + desiredAnswer);
		if (answer != desiredAnswer)
		{
			errors = true;
			System.out.println("DOESN'T MATCH!!!!");
		}
		else
			System.out.println("Match :-)");
		System.out.println();
		time = System.currentTimeMillis();
		answer = new Cut().getMaximum(new int[]{34, 10, 48}, 4);
		System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
		desiredAnswer = 5;
		System.out.println("Your answer:");
		System.out.println("\t" + answer);
		System.out.println("Desired answer:");
		System.out.println("\t" + desiredAnswer);
		if (answer != desiredAnswer)
		{
			errors = true;
			System.out.println("DOESN'T MATCH!!!!");
		}
		else
			System.out.println("Match :-)");
		System.out.println();
		time = System.currentTimeMillis();
		answer = new Cut().getMaximum(new int[]{30, 50, 30, 50}, 350);
		System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
		desiredAnswer = 16;
		System.out.println("Your answer:");
		System.out.println("\t" + answer);
		System.out.println("Desired answer:");
		System.out.println("\t" + desiredAnswer);
		if (answer != desiredAnswer)
		{
			errors = true;
			System.out.println("DOESN'T MATCH!!!!");
		}
		else
			System.out.println("Match :-)");
		System.out.println();
		
		
		if (errors)
			System.out.println("Some of the test cases had errors :-(");
		else
			System.out.println("You're a stud (at least on the test data)! :-D ");
	}

}
// Powered by [KawigiEdit] 2.0!
